﻿var mask;

/*
调用示例：
art.dialog.tips('请填写完整信息', 2000);
*/
artDialog.tips = function (content, time) {
    return artDialog({
        id: 'Tips',
        title: false,
        cancel: false,
        fixed: true,
        lock: true
    })
    .content(content)
	.time(time || 1);
};

/*
art.dialog.notice({
    title: '提示',
    width: 220,// 必须指定一个像素宽度值或者百分比，否则浏览器窗口改变可能导致artDialog收缩
    content: '尊敬的顾客朋友，您IQ卡余额不足10元，请及时充值',
    icon: 'face-sad',
    time: 5
});
*/
artDialog.notice = function (options) {
    var opt = options || {},
        api, aConfig, hide, wrap, top,
        duration = 800;

    var config = {
        id: 'Notice',
        left: '100%',
        top: '100%',
        fixed: true,
        drag: false,
        resize: false,
        follow: null,
        lock: false,
        init: function (here) {
            api = this;
            aConfig = api.config;
            wrap = api.DOM.wrap;
            top = parseInt(wrap[0].style.top);
            hide = top + wrap[0].offsetHeight;

            wrap.css('top', hide + 'px')
                .animate({ top: top + 'px' }, duration, function () {
                    opt.init && opt.init.call(api, here);
                });
        },
        close: function (here) {
            wrap.animate({ top: hide + 'px' }, duration, function () {
                opt.close && opt.close.call(this, here);
                aConfig.close = $.noop;
                api.close();
            });

            return false;
        }
    };

    for (var i in opt) {
        if (config[i] === undefined) config[i] = opt[i];
    };

    return artDialog(config);
};

function showTip(msg) {
    art.dialog.tips(msg, 2000);
}

function showNotice(msg, second) {
    if (!second) second = 3;

    art.dialog.notice({
        title: '提示',
        //width: 220,// 必须指定一个像素宽度值或者百分比，否则浏览器窗口改变可能导致artDialog收缩
        content: '温馨提示：' + msg,
        icon: 'face-sad',
        time: second * 1000
    });
}

function showMsg(msg, modal, okFun) {
    $(function() {
        art.dialog({
            title: '提示',
            content: '温馨提示：' + msg,
            lock: modal,
            okValue: '确定',
            ok: okFun
        });
    });
}


function showMask(title) {
    if (!title) title = '请稍后...';

    mask = art.dialog({
        title: title,
        content: '<img src="../../admin/plugin/artDialog/loading.gif" />',
        lock: true
    });
    
    return mask;
}

function hideMask() {
    mask.close();
}

function showConfirm(msg, okFun, noFun) {

    art.confirm('温馨提示：' + msg, okFun, noFun);

    /*var dialog = art.dialog({
        title: '提示',
        content: '温馨提示：' + msg,
        lock: true,
        button: [{
            value: '确定',            
            callback: function () {
                dialog.close();
                okFun();
                //return false;
            }
        }, {
            id: 'button',
            value: '取消',
            focus: true,
            callback: function () {
                dialog.close();
                noFun();
            }
        }]
    });*/
}

function showTip(msg) {
    
}

function showIframe(url, title, modal, width, height) {
    //alert(art.artDialog);

    var win = art.dialog({
        title: title,
        drag: true,
        content: '<iframe frameborder="0" src="' + url + '" width="' + width + '" height="' + height + '"></iframe>',
        padding: '0px',
        lock: modal
    });
    
    return win;
}

/*
调用方式：
showPrompt("请输入学号：", function (value) {
    alert(value)
}, "107062050");
*/
function showPrompt(msg, fun, defValue) {
    art.prompt(msg, fun, defValue);
}


(function (d) {
    d['okValue'] = '确定';
    d['cancelValue'] = '取消';
    d['title'] = '提示';
    // [more..]
})(art.dialog.defaults);